package com.ocn.li.scmdy.modules.app.controller;

import java.io.*;

/**
 * @ClassName a
 * @Description TODO
 * @Author Li9527
 * @Date 2020/10/9 14:35
 * @Version 1.0
 */
public class Test {

    // 字节缓冲流一次读写一个字节数组
    private static void  copyFile(File srcFile, File destFile) throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(srcFile));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(destFile));

        byte[] bys = new byte[1024];
        int i =0;
        int len = 0;
        while ((len = bis.read(bys)) != -1) {
            bos.write(bys, 0, len);
        }
        bos.close();
        bis.close();
    }


    public static void main(String[] args) throws IOException {
        long start = System.currentTimeMillis();
        File srcFile = new File("D:\\hy\\img\\a.png");
        File outFile = new File("D:\\hy\\img\\hhhhhhyh.png");
        copyFile(srcFile, outFile);
        long end = System.currentTimeMillis();
        System.out.print("花费时间：" + (end - start));
    }
}
